import 'package:distribution_mall_flutter/constant/cf_constant.dart';
import 'package:distribution_mall_flutter/generated/l10n.dart';
import 'package:distribution_mall_flutter/pages/message/widgets/message_card.dart';
import 'package:distribution_mall_flutter/widgets/list_scroll.dart';
import 'package:flutter/material.dart';
import 'package:flutter_popup/flutter_popup.dart';

class MessgeScrollPage extends StatefulWidget {
  const MessgeScrollPage({super.key});

  @override
  State<MessgeScrollPage> createState() {
    return _MessgeScrollPageState();
  }
}

class PopoverBuilder extends StatelessWidget {
  const PopoverBuilder({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
        width: 120,
        height: 66,
        // padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0),
        child: Column(children: [
          GestureDetector(
            onTap: () {
              Navigator.of(context).pop();
            },
            child: Container(
                height: 35,
                alignment: Alignment.center,
                padding: const EdgeInsets.only(bottom: EdgeConstant.edge10),
                child: Text(
                  S.of(context).message_allRead,
                  style: const TextStyle(
                      color: Color.fromRGBO(50, 50, 51, 1),
                      fontSize: FontConstant.f14),
                )),
          ),
          const Divider(
            height: 1,
            color: Color.fromRGBO(235, 237, 240, 1),
          ),
          GestureDetector(
            onTap: () {},
            child: Container(
                height: 30,
                padding: const EdgeInsets.only(top: EdgeConstant.edge10),
                alignment: Alignment.center,
                child: Text(S.of(context).message_delete,
                    style: const TextStyle(
                        color: Color.fromRGBO(50, 50, 51, 1),
                        fontSize: FontConstant.f14))),
          ),
        ]));
  }
}

class _MessgeScrollPageState extends State<MessgeScrollPage> {
  Object? dropdownValue;
  @override
  Widget build(BuildContext context) {
    return Expanded(
        child: Container(
            decoration: const BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(10),
                  topRight: Radius.circular(10),
                ),
                boxShadow: [
                  BoxShadow(
                      color: Color.fromRGBO(0, 0, 0, 0.1),
                      offset: Offset(0, 2),
                      // spreadRadius: 2,
                      blurRadius: 10)
                ]),
            child: EPListScroll(
              count: 10,
              listTitle: Padding(
                padding:
                    const EdgeInsets.symmetric(horizontal: EdgeConstant.edge20),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Expanded(
                      child: Text(
                        S.of(context).message_notification,
                        style: const TextStyle(
                            color: ColorConstant.black,
                            fontSize: FontConstant.f16,
                            fontWeight: FontWeight.bold),
                      ),
                    ),
                    TextButton(
                      onPressed: () {},
                      style: ButtonStyle(
                        padding: MaterialStateProperty.all<EdgeInsets>(
                            EdgeInsets.zero),
                        textStyle: MaterialStateProperty.all<TextStyle>(
                            const TextStyle(
                                color: Color.fromRGBO(156, 156, 156, 1),
                                fontSize: FontConstant.f14) // 设置文本颜色为红色
                            ),
                      ),
                      child: Text(S.of(context).message_allRead),
                    ),
                    const CustomPopup(
                        backgroundColor: Colors.white,
                        content: PopoverBuilder(),
                        barrierColor: Color.fromRGBO(0, 0, 0, 0),
                        child: SizedBox(
                          width: 40,
                          height: 20,
                          child: Icon(
                            Icons.more_horiz,
                            color: Color(0xbcbcbcff),
                          ),
                        )),
                  ],
                ),
              ),
              child: const MessageCard(),
            )));
  }
}
